package com.mj.haier.calc.servlet.impl;

import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.mj.haier.calc.servlet.Filter;
import com.mj.haier.calc.servlet.FilterChain;
import com.mj.haier.calc.servlet.Request;
import com.mj.haier.calc.servlet.Response;
import com.mj.haier.calc.servlet.ServletException;
import com.mj.haier.calc.domain.AzEorderSettlementProcess;

public class AllComplianceFilter implements Filter {

    private final Logger log = LoggerFactory.getLogger(AllComplianceFilter.class);

    @Override
    public void doFilter(Request req, Response res, FilterChain chain) throws IOException, ServletException {
        
        AzEorderSettlementProcess process = (AzEorderSettlementProcess)req.getObject();
        log.debug("AllComplianceFilter 过滤前 AzEorderSettlementProcess: {}", process.toString());

        if("0".equals(process.getAllCompliance())){
            chain.doFilter(req, res);
            return;
        }
        //所有合规性检验
        String compliance = "0";
        String carsteamCompliance = process.getCarsTeamCompliance();
        String carsCompliance = process.getCarsCompliance();
        String percentCompliance = process.getPercentCompliance();
        String levelCompliance = process.getLevelCompliance();
        if("0".equals(carsteamCompliance) && "0".equals(carsCompliance)
            && "0".equals(percentCompliance) && "0".equals(levelCompliance)){
        }else{
            compliance = "1";
        }

        process.allCompliance(compliance);
        chain.doFilter(req, res);
    }
}

